package StringExercise;

public class StringBuilderDemo2 {
    public static void main(String[] args) {
        /*
        //StringBuilder的创建方式
        StringBuilder builder3=new StringBuilder();
        StringBuilder builder4=new StringBuilder("aaaa");
        //String和StringBuilder之间的转换
        String str2="123";
        StringBuilder builder5=new StringBuilder(str2);
        String str3=builder5.toString();

         */

        String str2="好好学习java";
        StringBuilder builder2=new StringBuilder(str2);
        //append():追加内容----在末尾追加
        builder2.append(",为了找个好工作");
        System.out.println(builder2);
        //replace():替换部分内容(含头不含尾)
        builder2.replace(9,16,"就是为了改变世界");
        System.out.println(builder2);
        //delete():删除部分内容(含头不含尾)
        builder2.delete(0,8);
        System.out.println(builder2);
        //insert():插入内容
        builder2.insert(0,"活着");
        System.out.println(builder2);

    }
}
